﻿#region Header

/*
Remote views based on linq
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Security.Cryptography;
using System.Text;

#endregion

namespace InterLinq.Test {
	/// <summary>
	/// Represents a order that contains n order positions
	/// </summary>
	[Serializable]
	public class WPFOrder : INotifyPropertyChanged, IOrder {
		#region Public Properties

		/// <summary>
		/// Gets the order position of the order
		/// </summary>
		public virtual IList<IOrderPosition> OrderPositions { get; private set; }

		/// <summary>
		///  gets the unique id of the order
		/// </summary>
		public virtual Guid Id {
			get { return m_id; }
			private set {
				m_id = value;
				if (PropertyChanged != null) {
					PropertyChanged(this, new PropertyChangedEventArgs("Id"));
				}
			}
		}

		/// <summary>
		///  gets the name of the order
		/// </summary>
		public virtual string Name {
			get { return m_name; }
			set {
				m_name = value;
				if (PropertyChanged != null) {
					PropertyChanged(this, new PropertyChangedEventArgs("Name"));
				}
			}
		}

		#endregion

		#region Public Methods

		public WPFOrder() {
			OrderPositions = new List<IOrderPosition>();
			Id = Guid.NewGuid();
			Name = Encoding.ASCII.GetString(MD5.Create().ComputeHash(Id.ToByteArray()));
		}

		#endregion

		#region Private Fields

		private Guid m_id;
		private string m_name;

		#endregion

		#region Private Methods

		// private methods located here

		#endregion

		#region INotifyPropertyChanged Members

		public virtual event PropertyChangedEventHandler PropertyChanged;

		#endregion
	}
}